package core.report.yearReport.bean;

import org.springframework.jdbc.support.rowset.SqlRowSet;

import core.report.yearReport.util.ExportExcelUtil;

public class Brand extends BaseExcelReportDataBean {
	private String name;

	private String brand_name;
	private long total_pieces;
	private double pieces_price;
	private double amount;
	private double brand_per;
	private double gross_revenue;
	private double gross_per;
	private double cost_accomplish;
	private double wh_accomplish;
	private double per_pieces_count;
	private double per_pieces_price;
	
	public Brand() {
	}

	public Brand(SqlRowSet rs) {
		this.brand_name = rs.getString("brand_name");
		this.total_pieces = rs.getLong("total_pieces");
		this.pieces_price = rs.getDouble("pieces_price");
		this.amount = rs.getDouble("amount");
		this.brand_per = rs.getDouble("brand_per");
		this.gross_revenue = rs.getDouble("gross_revenue");
		this.gross_per = rs.getDouble("gross_per");
		this.cost_accomplish = rs.getDouble("cost_accomplish");
		this.wh_accomplish = rs.getDouble("wh_accomplish");
		this.per_pieces_count = rs.getDouble("per_pieces_count");
		this.per_pieces_price = rs.getDouble("per_pieces_price");
		
		this.name = this.brand_name;
	}

	public void addProperties(Brand data) {
		this.setTotal_pieces(this.getTotal_pieces()+data.getTotal_pieces());
		this.setPieces_price(this.getPieces_price()+data.getPieces_price());
		this.setAmount(this.getAmount()+data.getAmount());
		this.setBrand_per(this.getBrand_per()+data.getBrand_per());
		this.setGross_revenue(this.getGross_revenue()+data.getGross_revenue());
		this.setGross_per(this.getGross_per()+data.getGross_per());
		this.setCost_accomplish(this.getCost_accomplish()+data.getCost_accomplish());
		this.setWh_accomplish(this.getWh_accomplish()+data.getWh_accomplish());
		this.setPer_pieces_count(this.getPer_pieces_count()+data.getPer_pieces_count());
		this.setPer_pieces_price(this.getPer_pieces_price()+data.getPer_pieces_price());
	}

	public void subtract(int size) {
		if (size != 0) {
			this.setBrand_per(this.getBrand_per()/size);
			this.setGross_per(this.getGross_per()/size);
			this.setCost_accomplish(this.getCost_accomplish()/size);
			this.setWh_accomplish(this.getWh_accomplish()/size);
		} else {
			this.setBrand_per(0);
			this.setGross_per(0);
			this.setCost_accomplish(0);
			this.setWh_accomplish(0);
		}
	}

	@Override
	public int getFormatTypeByIndex(int index) {
		switch (index) {
		case 0:
			return ExportExcelUtil.TEXT_TYPE;
		case 1:
			return ExportExcelUtil.LONG_TYPE;
		case 2:
			return ExportExcelUtil.DECIMAL_TYPE;
		case 3:
			return ExportExcelUtil.DECIMAL_TYPE;
		case 4:
			return ExportExcelUtil.PERCENT_TYPE;
		case 5:
			return ExportExcelUtil.DECIMAL_TYPE;
		case 6:
			return ExportExcelUtil.PERCENT_TYPE;
		case 7:
			return ExportExcelUtil.PERCENT_TYPE;
		case 8:
			return ExportExcelUtil.PERCENT_TYPE;
		case 9:
			return ExportExcelUtil.DECIMAL_TYPE;
		case 10:
			return ExportExcelUtil.DECIMAL_TYPE;
		default:
			return ExportExcelUtil.TEXT_TYPE;
		}
	}

	@Override
	public String getValueByIndex(int index) {
		String value = "";
		switch (index) {
		case 0:
			value = this.getName();
			break;
		case 1:
			value = this.getTotal_pieces() + "";
			break;
		case 2:
			value = this.getPieces_price() + "";
			break;
		case 3:
			value = this.getAmount() + "";
			break;
		case 4:
			value = this.getBrand_per() + "";
			break;
		case 5:
			value = this.getGross_revenue() + "";
			break;
		case 6:
			value = this.getGross_per()+ "";
			break;
		case 7:
			value = this.getCost_accomplish() + "";
			break;
		case 8:
			value = this.getWh_accomplish() + "";
			break;
		case 9:
			value = this.getPer_pieces_count() + "";
			break;
		case 10:
			value = this.getPer_pieces_price()+ "";
			break;
		}
		return value;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getBrand_name() {
		return brand_name;
	}

	public void setBrand_name(String brand_name) {
		this.brand_name = brand_name;
	}

	public long getTotal_pieces() {
		return total_pieces;
	}

	public void setTotal_pieces(long total_pieces) {
		this.total_pieces = total_pieces;
	}

	public double getPieces_price() {
		return pieces_price;
	}

	public void setPieces_price(double pieces_price) {
		this.pieces_price = pieces_price;
	}

	public double getAmount() {
		return amount;
	}

	public void setAmount(double amount) {
		this.amount = amount;
	}

	public double getBrand_per() {
		return brand_per;
	}

	public void setBrand_per(double brand_per) {
		this.brand_per = brand_per;
	}

	public double getGross_revenue() {
		return gross_revenue;
	}

	public void setGross_revenue(double gross_revenue) {
		this.gross_revenue = gross_revenue;
	}

	public double getGross_per() {
		return gross_per;
	}

	public void setGross_per(double gross_per) {
		this.gross_per = gross_per;
	}

	public double getCost_accomplish() {
		return cost_accomplish;
	}

	public void setCost_accomplish(double cost_accomplish) {
		this.cost_accomplish = cost_accomplish;
	}

	public double getWh_accomplish() {
		return wh_accomplish;
	}

	public void setWh_accomplish(double wh_accomplish) {
		this.wh_accomplish = wh_accomplish;
	}

	public double getPer_pieces_count() {
		return per_pieces_count;
	}

	public void setPer_pieces_count(double per_pieces_count) {
		this.per_pieces_count = per_pieces_count;
	}

	public double getPer_pieces_price() {
		return per_pieces_price;
	}

	public void setPer_pieces_price(double per_pieces_price) {
		this.per_pieces_price = per_pieces_price;
	}

}
